package com.spic.business.train.trainUser.domain;

import com.spic.business.common.core.domain.BasicEntity;
import com.spic.common.core.annotation.Excel;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.Date;

/**
 * 培训用户对象 train_user
 *
 * @author spic
 * @date 2021-10-15
 */

@Builder
@Data
@NoArgsConstructor
@AllArgsConstructor
public class TrainUser extends BasicEntity
{
    private static final long serialVersionUID = 1L;

    /** $column.columnComment */
    private Long id;

    /** $column.columnComment */

    private String trainInfoId;

    /** $column.columnComment */

    private Long userId;
    @Excel(name = "培训用户")
    private String userName;

    /** 0 培训未完成  1 培训完成 */

    private Integer trainState;

    /** 证书id */

    private String certificateId;
    /** 证书附件名 */
    private String certificateFileName;
    /** 证书附件url */
    private String certificateFileUrl;


    /** 心得体会附件名 */
    private String trainExperienceFileName;
    /** 心得体会附件url */
    private String trainExperienceFileUrl;


    /** 培训进度 0-100 */

    private Integer trainSchedule;

    /** 0 培训合格 1培训不合格 */
    @Excel(name = "是否合格", readConverterExp = "0=合格,1=不合格")
    private String judge;

    private Date signTime;
    /**
     * 判断进度是否完成
     * @return
     */
    public boolean ScheduleFinshed() {
        return new Integer(100).equals(this.trainSchedule);
    }

    /**
     * 设置培训状态为已完成
     */
    public void setStateFinished(){
        setTrainState(1);
    }

    //更新进度
    public static TrainUser updateProcess(Long trainUserId, Integer trainSchedule){
        TrainUser trainUser =  TrainUser.builder()
                                            .id(trainUserId)
                                            .trainSchedule(trainSchedule)
                                            .judge("0")
                                            .build();
        if(trainUser.ScheduleFinshed()){
            trainUser.setStateFinished();
        }
        return trainUser;
    }

    public static long getSerialVersionUID() {
        return serialVersionUID;
    }


}
